Android SensorManager and sensormanager
Most Android devices have built-in sensors, some of which are hardware-based and some are software-based. Sensors can be used to monitor the 3D Motion and position of a device, and to infer user actions, such as skew, vibration, and rotation, and to monitor changes in the environ
The Android sensor Logoff method is:Public voidUnregisterlistener (Sensorlistener Listener) Use this method to unregister the listener.Today found that this method is not good to use, after the call, the sensor will not be canceled at all.No other cancellation method was found after the search.Debug with debug carefully look at the log, found that every time you enter the sensor interface activity, there are two sensors, which led to the destruction o
(0, 0,-10 );When the mobile phone screen is placed on the left (X axis to the day), the values of (x, y, z) are (10, 0, 0 );The values of (x, y, z) are (0, 10, 0) when the mobile phone is vertical (Y axis to day );The other analogy is that the day is a positive number, and the day is a negative number.Using the three values of X, Y, and Z to calculate the trigonometric function, you can precisely detect the motion of the mobile phone.
The function of the following code is to obtain a manager o
Well, thanks to the recent development requirements for smart hardware, so the recent days to share the blog is roughly linked to intelligent hardware, like a piece of Bluetooth sharing, I believe that many readers have seen, then today I bring you the knowledge of the Android sensor introduction and use of methods, for the use of sensors , different versions of the Android phone may have larger hardware di
[1]; // gravity acceleration in the y axisFloat z = values [2]; // acceleration of gravity in the z axis
The range of each value is-10 ~ Between 10, we can determine the value of each direction to achieve the effect we need, that is, when the value in each direction meets certain conditions, it triggers our expected event
Bytes ------------------------------------------------------------------------------------
PS: To avoid shaking or pop-up windows when there is no input, or continue shaking a
Android implements the shake function, and android implements the shake function.
To implement the "Shake" function, it is actually very simple. It is to detect the mobile phone's gravity sensor. The specific implementation code is as follows:
1. Add operation permissions in AndroidManifest. xml
II. Implementation Code
[Java]View plaincopy
Package com. xs. test;
Import
Let's take a look at the sensormanager code.
Sensormanager framework Layer Code
@ Frameworks/base/CORE/Java/Android/hardware/sensormanager. Java
Public sensormanager (lodomainmainloiter) {mmainloiter = mainloiter; // As mentioned above, this is the activity's lodomainsynchr
The above has already introduced the porting process of android temperature sensor. The code page has been posted to everyone. Now we can write an APK for testing. The code is very simple, and the interface is very simple and ugly. Haha, don't mind. This aok is only used for testing. I will not introduce it more here and paste the Code directly.Package com. android. jay. sensor1;Import
For convenience, Roboguice provides "standard injection" support for some of the objects or services commonly used on the Android platform. For example, you do not need to use (Sensormanager) Getsystemservice (Sensor_service) to obtain a Sensormanger instance and use the @inject tag directly
@Inject Sensormanager Sensormanag
In the previous example, the Android ApiDemos example resolution (61): Graphics-> Compass and the Android ApiDemos example resolution (79): Graphics-> SensorTest involves Sensors.
This example introduces the Sensors usage supported by Android.
SensorManager is used to manage various sensors in
Android development: Android device sensor Development Summary, android Sensor
In this article, I will share with you how to develop Android device sensors.
Please indicate the author xiong_it and link: http://blog.csdn.net/xiong_it/article/details/45917009
Android sensor de
Implementation of android level (use of direction sensors)
A long time ago, I have studied the Sensor. TYPE_ORIENTATION. According to my own practice, I have rewritten the two online leveling examples, re-encapsulated and used them, and finally used them in projects.1. Preface
The following is a sensor from the Android sensor.
Generally, in the android system, t
The instructor of the fetc project proposed a new requirement. He wanted to show the user's current movement direction in the game map. If he used GPS, it was obviously unreliable, so he thought of the powerful Android sensor...
Many mobile devices have built-in sensors. Android abstracts these sensors through the sensor and sensormanager classes, and these sen
usually obtain data by measuring attributes of special environments, such as changes in gravity acceleration, geomagnetic intensity, or azimuth angle. Software-based sensors do not rely on physical devices, though they mimic hardware-based sensors. Software-based sensors usually obtain data through one or more hardware sensors, and sometimes call virtual sensors or artificial sensors, linear accelerometer and gravity sensor are examples of software-based sensors. The following figure shows all
Android --- 57 --- sensor, android Sensor
The Android system provides support for sensors.Developing an application sensor is simple. You only need to register a listener for the specified listener.
Steps:1. Call the getSystemService (Context. SENSOR_SERVICE) method of Context to obtain the SensorManager object. The
Android obtains basic three-axis knowledge
Basic knowledge
Rotation Angle around the Z axis: Azimuth, I call it the north-facing corner (the north-facing direction of the compass)
Rotation Angle around the X axis: Pitch.
Rotation Angle around the Y axis: Roll, I call it the left and right corner.
Solution 1: Magnetic Field Sensor + acceleration sensor (recommended)
Step 1: Obtain sensor system services
Private
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.